Skip to content

feat(billing): EN16931 + Romanian law PDF compliance (#153)#166

Open
b3lz3but wants to merge 2 commits intocaptainpragmatic:masterfrom
b3lz3but:feat/pdf-en16931-compliance
Open

feat(billing): EN16931 + Romanian law PDF compliance (#153)#166
b3lz3but wants to merge 2 commits intocaptainpragmatic:masterfrom
b3lz3but:feat/pdf-en16931-compliance

Conversation

@b3lz3but
Copy link
Copy Markdown
Contributor

@b3lz3but b3lz3but commented Apr 1, 2026

Summary

Enhances the ReportLab PDF generator for invoices and proformas with EN16931-compliant fields and Romanian legal requirements. No WeasyPrint migration (deferred) — builds on the existing coordinate-based approach.

Closes #153

What changed

Seller section — now renders: registration number (Nr. Reg. Com.), phone, bank name, IBAN. New settings: COMPANY_REGISTRATION_NUMBER, COMPANY_BANK_NAME, COMPANY_BANK_ACCOUNT.

Client section — renders full address: bill_to_address1, bill_to_address2, city/region/postal/country, CUI/CIF, registration number (new bill_to_registration_number field), email. Dynamic y-stepping skips empty fields.

Items table — 5 columns (added VAT%). EN16931 sub-lines below each item: domain name, service period (dd.mm.yyyy), SKU/product code. Line-level discounts rendered. Currency code from invoice model, not hardcoded "RON".

Totals section — VAT breakdown per rate (groups lines by tax_rate). Reverse charge notation ("Taxare inversă — Art. 331 Cod Fiscal") when tax_category_code=AE. Exchange rate line for non-RON invoices from meta.exchange_rate.

Legal disclaimers — Invoice: "Factură fiscală emisă conform art. 319 din Legea nr. 227/2015". Proforma: "Factura proforma nu constituie document fiscal."

Model changes — Added bill_to_registration_number (CharField, blank) to both Invoice and ProformaInvoice. Migration 0025.

Files changed

File Change
apps/billing/pdf_generators.py Expanded from 386→593 lines: all rendering methods enhanced
config/settings/base.py 3 new COMPANY_* settings
apps/billing/invoice_models.py bill_to_registration_number field
apps/billing/proforma_models.py bill_to_registration_number field
apps/billing/migrations/0025_* Schema migration
tests/billing/test_pdf_generators.py 12 new EN16931 tests + updated existing tests

Deferred to follow-up

  • PDF/A-3 with embedded UBL XML (requires pikepdf)
  • Amount in words in Romanian
  • Invoice series concept (serie + numar)
  • WeasyPrint migration

Test plan

  • 78 PDF generator tests pass (12 new EN16931 + 66 existing updated)
  • All pre-commit hooks pass
  • DCO sign-off present
  • Visual review: generate PDF with mixed VAT rates, full address, EN16931 line fields

🤖 Generated with Claude Code

…ptainpragmatic#153)

Enhance the ReportLab PDF generator with EN16931-compliant fields and
Romanian legal requirements:

- VAT breakdown per rate (not hardcoded 21%)
- Full client address with registration number and tax ID
- Seller bank details (IBAN, bank name) and registration number
- EN16931 line-level fields: domain name, service period, SKU
- Reverse charge notation for intra-EU B2B (tax_category_code=AE)
- Exchange rate display for non-RON currencies
- Updated fiscal disclaimers per Romanian legislation
- Dynamic currency codes from invoice model (not hardcoded RON)
- Line-level discount rendering
- bill_to_registration_number field on Invoice and ProformaInvoice

Closes captainpragmatic#153

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ciprian Radulescu <craps2003@gmail.com>
@b3lz3but
Copy link
Copy Markdown
Contributor Author

b3lz3but commented Apr 1, 2026

@mostlyvirtual — requesting review on this EN16931 PDF compliance PR.

The comprehensive test file asserted old English disclaimer text and
hardcoded RON currency. Updated to match new Romanian-language
disclaimers and dynamic {currency} placeholder in total labels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ciprian Radulescu <craps2003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(billing): PDF generation EN16931 + Romanian law compliance

1 participant